3.1.61 \(\int \frac {(c+d \tan (e+f x))^2 (A+B \tan (e+f x)+C \tan ^2(e+f x))}{a+b \tan (e+f x)} \, dx\) [61]

3.1.61.1 Optimal result
3.1.61.2 Mathematica [C] (verified)
3.1.61.3 Rubi [A] (verified)
3.1.61.4 Maple [A] (verified)
3.1.61.5 Fricas [A] (verification not implemented)
3.1.61.6 Sympy [C] (verification not implemented)
3.1.61.7 Maxima [A] (verification not implemented)
3.1.61.8 Giac [A] (verification not implemented)
3.1.61.9 Mupad [B] (verification not implemented)

3.1.61.1 Optimal result

Integrand size = 45, antiderivative size = 254 \[ \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=-\frac {\left (a \left (c^2 C+2 B c d-C d^2-A \left (c^2-d^2\right )\right )-b \left (2 c (A-C) d+B \left (c^2-d^2\right )\right )\right ) x}{a^2+b^2}-\frac {\left (a \left (B c^2-2 c C d-B d^2\right )+b \left (c^2 C+2 B c d-C d^2\right )+A \left (2 a c d-b \left (c^2-d^2\right )\right )\right ) \log (\cos (e+f x))}{\left (a^2+b^2\right ) f}+\frac {\left (A b^2-a (b B-a C)\right ) (b c-a d)^2 \log (a+b \tan (e+f x))}{b^3 \left (a^2+b^2\right ) f}+\frac {d (b c C+b B d-a C d) \tan (e+f x)}{b^2 f}+\frac {C (c+d \tan (e+f x))^2}{2 b f} \]

output
-(a*(c^2*C+2*B*c*d-C*d^2-A*(c^2-d^2))-b*(2*c*(A-C)*d+B*(c^2-d^2)))*x/(a^2+ 
b^2)-(a*(B*c^2-B*d^2-2*C*c*d)+b*(2*B*c*d+C*c^2-C*d^2)+A*(2*a*c*d-b*(c^2-d^ 
2)))*ln(cos(f*x+e))/(a^2+b^2)/f+(A*b^2-a*(B*b-C*a))*(-a*d+b*c)^2*ln(a+b*ta 
n(f*x+e))/b^3/(a^2+b^2)/f+d*(B*b*d-C*a*d+C*b*c)*tan(f*x+e)/b^2/f+1/2*C*(c+ 
d*tan(f*x+e))^2/b/f
 
3.1.61.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 3.21 (sec) , antiderivative size = 190, normalized size of antiderivative = 0.75 \[ \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=\frac {\frac {b (-i A+B+i C) (c+i d)^2 \log (i-\tan (e+f x))}{a+i b}+\frac {b (i A+B-i C) (c-i d)^2 \log (i+\tan (e+f x))}{a-i b}+\frac {2 \left (A b^2+a (-b B+a C)\right ) (b c-a d)^2 \log (a+b \tan (e+f x))}{b^2 \left (a^2+b^2\right )}+\frac {2 d (b c C+b B d-a C d) \tan (e+f x)}{b}+C (c+d \tan (e+f x))^2}{2 b f} \]

input
Integrate[((c + d*Tan[e + f*x])^2*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)) 
/(a + b*Tan[e + f*x]),x]
 
output
((b*((-I)*A + B + I*C)*(c + I*d)^2*Log[I - Tan[e + f*x]])/(a + I*b) + (b*( 
I*A + B - I*C)*(c - I*d)^2*Log[I + Tan[e + f*x]])/(a - I*b) + (2*(A*b^2 + 
a*(-(b*B) + a*C))*(b*c - a*d)^2*Log[a + b*Tan[e + f*x]])/(b^2*(a^2 + b^2)) 
 + (2*d*(b*c*C + b*B*d - a*C*d)*Tan[e + f*x])/b + C*(c + d*Tan[e + f*x])^2 
)/(2*b*f)
 
3.1.61.3 Rubi [A] (verified)

Time = 1.46 (sec) , antiderivative size = 268, normalized size of antiderivative = 1.06, number of steps used = 13, number of rules used = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.267, Rules used = {3042, 4130, 27, 3042, 4120, 25, 3042, 4109, 3042, 3956, 4100, 16}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan (e+f x)^2\right )}{a+b \tan (e+f x)}dx\)

\(\Big \downarrow \) 4130

\(\displaystyle \frac {\int \frac {2 (c+d \tan (e+f x)) \left ((b c C-a d C+b B d) \tan ^2(e+f x)+b (B c+(A-C) d) \tan (e+f x)+A b c-a C d\right )}{a+b \tan (e+f x)}dx}{2 b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {\int \frac {(c+d \tan (e+f x)) \left ((b c C-a d C+b B d) \tan ^2(e+f x)+b (B c+(A-C) d) \tan (e+f x)+A b c-a C d\right )}{a+b \tan (e+f x)}dx}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \frac {(c+d \tan (e+f x)) \left ((b c C-a d C+b B d) \tan (e+f x)^2+b (B c+(A-C) d) \tan (e+f x)+A b c-a C d\right )}{a+b \tan (e+f x)}dx}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 4120

\(\displaystyle \frac {\frac {d \tan (e+f x) (-a C d+b B d+b c C)}{b f}-\frac {\int -\frac {A c^2 b^2+\left (2 c (A-C) d+B \left (c^2-d^2\right )\right ) \tan (e+f x) b^2+\left (\left (C c^2+2 B d c+(A-C) d^2\right ) b^2-a d (2 c C+B d) b+a^2 C d^2\right ) \tan ^2(e+f x)-a d (2 b c C-a d C+b B d)}{a+b \tan (e+f x)}dx}{b}}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {\frac {\int \frac {A c^2 b^2+\left (2 c (A-C) d+B \left (c^2-d^2\right )\right ) \tan (e+f x) b^2+\left (\left (C c^2+2 B d c+(A-C) d^2\right ) b^2-a d (2 c C+B d) b+a^2 C d^2\right ) \tan ^2(e+f x)+a d (a C d-b (2 c C+B d))}{a+b \tan (e+f x)}dx}{b}+\frac {d \tan (e+f x) (-a C d+b B d+b c C)}{b f}}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {\int \frac {A c^2 b^2+\left (2 c (A-C) d+B \left (c^2-d^2\right )\right ) \tan (e+f x) b^2+\left (\left (C c^2+2 B d c+(A-C) d^2\right ) b^2-a d (2 c C+B d) b+a^2 C d^2\right ) \tan (e+f x)^2+a d (a C d-b (2 c C+B d))}{a+b \tan (e+f x)}dx}{b}+\frac {d \tan (e+f x) (-a C d+b B d+b c C)}{b f}}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 4109

\(\displaystyle \frac {\frac {\frac {b^2 \left (2 a A c d+a B \left (c^2-d^2\right )-2 a c C d-A b \left (c^2-d^2\right )+b \left (2 B c d+c^2 C-C d^2\right )\right ) \int \tan (e+f x)dx}{a^2+b^2}+\frac {(b c-a d)^2 \left (A b^2-a (b B-a C)\right ) \int \frac {\tan ^2(e+f x)+1}{a+b \tan (e+f x)}dx}{a^2+b^2}-\frac {b^2 x \left (a \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )-b \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )}{a^2+b^2}}{b}+\frac {d \tan (e+f x) (-a C d+b B d+b c C)}{b f}}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {\frac {b^2 \left (2 a A c d+a B \left (c^2-d^2\right )-2 a c C d-A b \left (c^2-d^2\right )+b \left (2 B c d+c^2 C-C d^2\right )\right ) \int \tan (e+f x)dx}{a^2+b^2}+\frac {(b c-a d)^2 \left (A b^2-a (b B-a C)\right ) \int \frac {\tan (e+f x)^2+1}{a+b \tan (e+f x)}dx}{a^2+b^2}-\frac {b^2 x \left (a \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )-b \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )}{a^2+b^2}}{b}+\frac {d \tan (e+f x) (-a C d+b B d+b c C)}{b f}}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 3956

\(\displaystyle \frac {\frac {\frac {(b c-a d)^2 \left (A b^2-a (b B-a C)\right ) \int \frac {\tan (e+f x)^2+1}{a+b \tan (e+f x)}dx}{a^2+b^2}-\frac {b^2 \log (\cos (e+f x)) \left (2 a A c d+a B \left (c^2-d^2\right )-2 a c C d-A b \left (c^2-d^2\right )+b \left (2 B c d+c^2 C-C d^2\right )\right )}{f \left (a^2+b^2\right )}-\frac {b^2 x \left (a \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )-b \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )}{a^2+b^2}}{b}+\frac {d \tan (e+f x) (-a C d+b B d+b c C)}{b f}}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 4100

\(\displaystyle \frac {\frac {\frac {(b c-a d)^2 \left (A b^2-a (b B-a C)\right ) \int \frac {1}{a+b \tan (e+f x)}d(b \tan (e+f x))}{b f \left (a^2+b^2\right )}-\frac {b^2 \log (\cos (e+f x)) \left (2 a A c d+a B \left (c^2-d^2\right )-2 a c C d-A b \left (c^2-d^2\right )+b \left (2 B c d+c^2 C-C d^2\right )\right )}{f \left (a^2+b^2\right )}-\frac {b^2 x \left (a \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )-b \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )}{a^2+b^2}}{b}+\frac {d \tan (e+f x) (-a C d+b B d+b c C)}{b f}}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

\(\Big \downarrow \) 16

\(\displaystyle \frac {\frac {-\frac {b^2 \log (\cos (e+f x)) \left (2 a A c d+a B \left (c^2-d^2\right )-2 a c C d-A b \left (c^2-d^2\right )+b \left (2 B c d+c^2 C-C d^2\right )\right )}{f \left (a^2+b^2\right )}-\frac {b^2 x \left (a \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )-b \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )}{a^2+b^2}+\frac {(b c-a d)^2 \left (A b^2-a (b B-a C)\right ) \log (a+b \tan (e+f x))}{b f \left (a^2+b^2\right )}}{b}+\frac {d \tan (e+f x) (-a C d+b B d+b c C)}{b f}}{b}+\frac {C (c+d \tan (e+f x))^2}{2 b f}\)

input
Int[((c + d*Tan[e + f*x])^2*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2))/(a + 
b*Tan[e + f*x]),x]
 
output
(C*(c + d*Tan[e + f*x])^2)/(2*b*f) + ((-((b^2*(a*(c^2*C + 2*B*c*d - C*d^2 
- A*(c^2 - d^2)) - b*(2*c*(A - C)*d + B*(c^2 - d^2)))*x)/(a^2 + b^2)) - (b 
^2*(2*a*A*c*d - 2*a*c*C*d - A*b*(c^2 - d^2) + a*B*(c^2 - d^2) + b*(c^2*C + 
 2*B*c*d - C*d^2))*Log[Cos[e + f*x]])/((a^2 + b^2)*f) + ((A*b^2 - a*(b*B - 
 a*C))*(b*c - a*d)^2*Log[a + b*Tan[e + f*x]])/(b*(a^2 + b^2)*f))/b + (d*(b 
*c*C + b*B*d - a*C*d)*Tan[e + f*x])/(b*f))/b
 

3.1.61.3.1 Defintions of rubi rules used

rule 16
Int[(c_.)/((a_.) + (b_.)*(x_)), x_Symbol] :> Simp[c*(Log[RemoveContent[a + 
b*x, x]]/b), x] /; FreeQ[{a, b, c}, x]
 

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4100
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + 
 (f_.)*(x_)]^2), x_Symbol] :> Simp[A/(b*f)   Subst[Int[(a + x)^m, x], x, b* 
Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]
 

rule 4109
Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2 
)/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*A + b*B - a 
*C)*(x/(a^2 + b^2)), x] + (Simp[(A*b^2 - a*b*B + a^2*C)/(a^2 + b^2)   Int[( 
1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x]), x], x] - Simp[(A*b - a*B - b*C)/( 
a^2 + b^2)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, e, f, A, B, C}, x] & 
& NeQ[A*b^2 - a*b*B + a^2*C, 0] && NeQ[a^2 + b^2, 0] && NeQ[A*b - a*B - b*C 
, 0]
 

rule 4120
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f 
_.)*(x_)]^2), x_Symbol] :> Simp[b*C*Tan[e + f*x]*((c + d*Tan[e + f*x])^(n + 
 1)/(d*f*(n + 2))), x] - Simp[1/(d*(n + 2))   Int[(c + d*Tan[e + f*x])^n*Si 
mp[b*c*C - a*A*d*(n + 2) - (A*b + a*B - b*C)*d*(n + 2)*Tan[e + f*x] - (a*C* 
d*(n + 2) - b*(c*C - B*d*(n + 2)))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[c^2 + d^2, 0] && 
  !LtQ[n, -1]
 

rule 4130
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) 
+ (f_.)*(x_)])^(n_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_. 
) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*(a + b*Tan[e + f*x])^m*((c + d*Tan[ 
e + f*x])^(n + 1)/(d*f*(m + n + 1))), x] + Simp[1/(d*(m + n + 1))   Int[(a 
+ b*Tan[e + f*x])^(m - 1)*(c + d*Tan[e + f*x])^n*Simp[a*A*d*(m + n + 1) - C 
*(b*c*m + a*d*(n + 1)) + d*(A*b + a*B - b*C)*(m + n + 1)*Tan[e + f*x] - (C* 
m*(b*c - a*d) - b*B*d*(m + n + 1))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && 
 NeQ[c^2 + d^2, 0] && GtQ[m, 0] &&  !(IGtQ[n, 0] && ( !IntegerQ[m] || (EqQ[ 
c, 0] && NeQ[a, 0])))
 
3.1.61.4 Maple [A] (verified)

Time = 0.18 (sec) , antiderivative size = 317, normalized size of antiderivative = 1.25

method result size
derivativedivides \(\frac {\frac {d \left (\frac {\tan \left (f x +e \right )^{2} C b d}{2}+\tan \left (f x +e \right ) b d B -\tan \left (f x +e \right ) C a d +2 \tan \left (f x +e \right ) C b c \right )}{b^{2}}+\frac {\left (A \,a^{2} d^{2} b^{2}-2 A a \,b^{3} c d +A \,b^{4} c^{2}-B \,a^{3} d^{2} b +2 B \,a^{2} c d \,b^{2}-B a \,b^{3} c^{2}+a^{4} C \,d^{2}-2 C \,a^{3} c d b +C \,a^{2} c^{2} b^{2}\right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{b^{3} \left (a^{2}+b^{2}\right )}+\frac {\frac {\left (2 A a c d -A b \,c^{2}+A b \,d^{2}+B a \,c^{2}-B a \,d^{2}+2 B b c d -2 C a c d +C b \,c^{2}-C b \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A a \,c^{2}-A a \,d^{2}+2 A b c d -2 B a c d +B b \,c^{2}-B b \,d^{2}-C a \,c^{2}+C a \,d^{2}-2 C b c d \right ) \arctan \left (\tan \left (f x +e \right )\right )}{a^{2}+b^{2}}}{f}\) \(317\)
default \(\frac {\frac {d \left (\frac {\tan \left (f x +e \right )^{2} C b d}{2}+\tan \left (f x +e \right ) b d B -\tan \left (f x +e \right ) C a d +2 \tan \left (f x +e \right ) C b c \right )}{b^{2}}+\frac {\left (A \,a^{2} d^{2} b^{2}-2 A a \,b^{3} c d +A \,b^{4} c^{2}-B \,a^{3} d^{2} b +2 B \,a^{2} c d \,b^{2}-B a \,b^{3} c^{2}+a^{4} C \,d^{2}-2 C \,a^{3} c d b +C \,a^{2} c^{2} b^{2}\right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{b^{3} \left (a^{2}+b^{2}\right )}+\frac {\frac {\left (2 A a c d -A b \,c^{2}+A b \,d^{2}+B a \,c^{2}-B a \,d^{2}+2 B b c d -2 C a c d +C b \,c^{2}-C b \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A a \,c^{2}-A a \,d^{2}+2 A b c d -2 B a c d +B b \,c^{2}-B b \,d^{2}-C a \,c^{2}+C a \,d^{2}-2 C b c d \right ) \arctan \left (\tan \left (f x +e \right )\right )}{a^{2}+b^{2}}}{f}\) \(317\)
norman \(\frac {\left (A a \,c^{2}-A a \,d^{2}+2 A b c d -2 B a c d +B b \,c^{2}-B b \,d^{2}-C a \,c^{2}+C a \,d^{2}-2 C b c d \right ) x}{a^{2}+b^{2}}+\frac {d \left (b d B -C a d +2 C b c \right ) \tan \left (f x +e \right )}{b^{2} f}+\frac {C \,d^{2} \tan \left (f x +e \right )^{2}}{2 b f}+\frac {\left (A \,a^{2} d^{2} b^{2}-2 A a \,b^{3} c d +A \,b^{4} c^{2}-B \,a^{3} d^{2} b +2 B \,a^{2} c d \,b^{2}-B a \,b^{3} c^{2}+a^{4} C \,d^{2}-2 C \,a^{3} c d b +C \,a^{2} c^{2} b^{2}\right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right ) b^{3} f}+\frac {\left (2 A a c d -A b \,c^{2}+A b \,d^{2}+B a \,c^{2}-B a \,d^{2}+2 B b c d -2 C a c d +C b \,c^{2}-C b \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f \left (a^{2}+b^{2}\right )}\) \(318\)
parallelrisch \(\frac {2 A \ln \left (a +b \tan \left (f x +e \right )\right ) a^{2} b^{2} d^{2}+B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a \,b^{3} c^{2}-B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a \,b^{3} d^{2}+2 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{4} c d -2 B \ln \left (a +b \tan \left (f x +e \right )\right ) a^{3} b \,d^{2}-2 B \ln \left (a +b \tan \left (f x +e \right )\right ) a \,b^{3} c^{2}+2 C \ln \left (a +b \tan \left (f x +e \right )\right ) a^{2} b^{2} c^{2}+2 B \tan \left (f x +e \right ) a^{2} b^{2} d^{2}-2 C \tan \left (f x +e \right ) a^{3} b \,d^{2}-2 C \tan \left (f x +e \right ) a \,b^{3} d^{2}+4 C \tan \left (f x +e \right ) b^{4} c d +2 B x \,b^{4} c^{2} f -2 B x \,b^{4} d^{2} f +C \tan \left (f x +e \right )^{2} a^{2} b^{2} d^{2}+2 B \tan \left (f x +e \right ) b^{4} d^{2}+C \tan \left (f x +e \right )^{2} b^{4} d^{2}-A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{4} c^{2}+A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{4} d^{2}+2 A \ln \left (a +b \tan \left (f x +e \right )\right ) b^{4} c^{2}+C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{4} c^{2}-C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{4} d^{2}+2 C \ln \left (a +b \tan \left (f x +e \right )\right ) a^{4} d^{2}+4 C \tan \left (f x +e \right ) a^{2} b^{2} c d +2 A x a \,b^{3} c^{2} f -2 A x a \,b^{3} d^{2} f +4 A x \,b^{4} c d f -2 C x a \,b^{3} c^{2} f +2 C x a \,b^{3} d^{2} f -4 C x \,b^{4} c d f +2 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a \,b^{3} c d -4 A \ln \left (a +b \tan \left (f x +e \right )\right ) a \,b^{3} c d +4 B \ln \left (a +b \tan \left (f x +e \right )\right ) a^{2} b^{2} c d -2 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a \,b^{3} c d -4 C \ln \left (a +b \tan \left (f x +e \right )\right ) a^{3} b c d -4 B x a \,b^{3} c d f}{2 \left (a^{2}+b^{2}\right ) b^{3} f}\) \(619\)
risch \(\text {Expression too large to display}\) \(1458\)

input
int((c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(a+b*tan(f*x+e)),x, 
method=_RETURNVERBOSE)
 
output
1/f*(d/b^2*(1/2*tan(f*x+e)^2*C*b*d+tan(f*x+e)*b*d*B-tan(f*x+e)*C*a*d+2*tan 
(f*x+e)*C*b*c)+1/b^3*(A*a^2*b^2*d^2-2*A*a*b^3*c*d+A*b^4*c^2-B*a^3*b*d^2+2* 
B*a^2*b^2*c*d-B*a*b^3*c^2+C*a^4*d^2-2*C*a^3*b*c*d+C*a^2*b^2*c^2)/(a^2+b^2) 
*ln(a+b*tan(f*x+e))+1/(a^2+b^2)*(1/2*(2*A*a*c*d-A*b*c^2+A*b*d^2+B*a*c^2-B* 
a*d^2+2*B*b*c*d-2*C*a*c*d+C*b*c^2-C*b*d^2)*ln(1+tan(f*x+e)^2)+(A*a*c^2-A*a 
*d^2+2*A*b*c*d-2*B*a*c*d+B*b*c^2-B*b*d^2-C*a*c^2+C*a*d^2-2*C*b*c*d)*arctan 
(tan(f*x+e))))
 
3.1.61.5 Fricas [A] (verification not implemented)

Time = 0.49 (sec) , antiderivative size = 397, normalized size of antiderivative = 1.56 \[ \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=\frac {{\left (C a^{2} b^{2} + C b^{4}\right )} d^{2} \tan \left (f x + e\right )^{2} + 2 \, {\left ({\left ({\left (A - C\right )} a b^{3} + B b^{4}\right )} c^{2} - 2 \, {\left (B a b^{3} - {\left (A - C\right )} b^{4}\right )} c d - {\left ({\left (A - C\right )} a b^{3} + B b^{4}\right )} d^{2}\right )} f x + {\left ({\left (C a^{2} b^{2} - B a b^{3} + A b^{4}\right )} c^{2} - 2 \, {\left (C a^{3} b - B a^{2} b^{2} + A a b^{3}\right )} c d + {\left (C a^{4} - B a^{3} b + A a^{2} b^{2}\right )} d^{2}\right )} \log \left (\frac {b^{2} \tan \left (f x + e\right )^{2} + 2 \, a b \tan \left (f x + e\right ) + a^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left ({\left (C a^{2} b^{2} + C b^{4}\right )} c^{2} - 2 \, {\left (C a^{3} b - B a^{2} b^{2} + C a b^{3} - B b^{4}\right )} c d + {\left (C a^{4} - B a^{3} b + A a^{2} b^{2} - B a b^{3} + {\left (A - C\right )} b^{4}\right )} d^{2}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 2 \, {\left (2 \, {\left (C a^{2} b^{2} + C b^{4}\right )} c d - {\left (C a^{3} b - B a^{2} b^{2} + C a b^{3} - B b^{4}\right )} d^{2}\right )} \tan \left (f x + e\right )}{2 \, {\left (a^{2} b^{3} + b^{5}\right )} f} \]

input
integrate((c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(a+b*tan(f*x+ 
e)),x, algorithm="fricas")
 
output
1/2*((C*a^2*b^2 + C*b^4)*d^2*tan(f*x + e)^2 + 2*(((A - C)*a*b^3 + B*b^4)*c 
^2 - 2*(B*a*b^3 - (A - C)*b^4)*c*d - ((A - C)*a*b^3 + B*b^4)*d^2)*f*x + (( 
C*a^2*b^2 - B*a*b^3 + A*b^4)*c^2 - 2*(C*a^3*b - B*a^2*b^2 + A*a*b^3)*c*d + 
 (C*a^4 - B*a^3*b + A*a^2*b^2)*d^2)*log((b^2*tan(f*x + e)^2 + 2*a*b*tan(f* 
x + e) + a^2)/(tan(f*x + e)^2 + 1)) - ((C*a^2*b^2 + C*b^4)*c^2 - 2*(C*a^3* 
b - B*a^2*b^2 + C*a*b^3 - B*b^4)*c*d + (C*a^4 - B*a^3*b + A*a^2*b^2 - B*a* 
b^3 + (A - C)*b^4)*d^2)*log(1/(tan(f*x + e)^2 + 1)) + 2*(2*(C*a^2*b^2 + C* 
b^4)*c*d - (C*a^3*b - B*a^2*b^2 + C*a*b^3 - B*b^4)*d^2)*tan(f*x + e))/((a^ 
2*b^3 + b^5)*f)
 
3.1.61.6 Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 2.17 (sec) , antiderivative size = 4444, normalized size of antiderivative = 17.50 \[ \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=\text {Too large to display} \]

input
integrate((c+d*tan(f*x+e))**2*(A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(a+b*tan(f* 
x+e)),x)
 
output
Piecewise((zoo*x*(c + d*tan(e))**2*(A + B*tan(e) + C*tan(e)**2)/tan(e), Eq 
(a, 0) & Eq(b, 0) & Eq(f, 0)), ((A*c**2*x + A*c*d*log(tan(e + f*x)**2 + 1) 
/f - A*d**2*x + A*d**2*tan(e + f*x)/f + B*c**2*log(tan(e + f*x)**2 + 1)/(2 
*f) - 2*B*c*d*x + 2*B*c*d*tan(e + f*x)/f - B*d**2*log(tan(e + f*x)**2 + 1) 
/(2*f) + B*d**2*tan(e + f*x)**2/(2*f) - C*c**2*x + C*c**2*tan(e + f*x)/f - 
 C*c*d*log(tan(e + f*x)**2 + 1)/f + C*c*d*tan(e + f*x)**2/f + C*d**2*x + C 
*d**2*tan(e + f*x)**3/(3*f) - C*d**2*tan(e + f*x)/f)/a, Eq(b, 0)), (I*A*c* 
*2*f*x*tan(e + f*x)/(2*b*f*tan(e + f*x) - 2*I*b*f) + A*c**2*f*x/(2*b*f*tan 
(e + f*x) - 2*I*b*f) + I*A*c**2/(2*b*f*tan(e + f*x) - 2*I*b*f) + 2*A*c*d*f 
*x*tan(e + f*x)/(2*b*f*tan(e + f*x) - 2*I*b*f) - 2*I*A*c*d*f*x/(2*b*f*tan( 
e + f*x) - 2*I*b*f) - 2*A*c*d/(2*b*f*tan(e + f*x) - 2*I*b*f) + I*A*d**2*f* 
x*tan(e + f*x)/(2*b*f*tan(e + f*x) - 2*I*b*f) + A*d**2*f*x/(2*b*f*tan(e + 
f*x) - 2*I*b*f) + A*d**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(2*b*f*tan( 
e + f*x) - 2*I*b*f) - I*A*d**2*log(tan(e + f*x)**2 + 1)/(2*b*f*tan(e + f*x 
) - 2*I*b*f) - I*A*d**2/(2*b*f*tan(e + f*x) - 2*I*b*f) + B*c**2*f*x*tan(e 
+ f*x)/(2*b*f*tan(e + f*x) - 2*I*b*f) - I*B*c**2*f*x/(2*b*f*tan(e + f*x) - 
 2*I*b*f) - B*c**2/(2*b*f*tan(e + f*x) - 2*I*b*f) + 2*I*B*c*d*f*x*tan(e + 
f*x)/(2*b*f*tan(e + f*x) - 2*I*b*f) + 2*B*c*d*f*x/(2*b*f*tan(e + f*x) - 2* 
I*b*f) + 2*B*c*d*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(2*b*f*tan(e + f*x) 
 - 2*I*b*f) - 2*I*B*c*d*log(tan(e + f*x)**2 + 1)/(2*b*f*tan(e + f*x) - ...
 
3.1.61.7 Maxima [A] (verification not implemented)

Time = 0.31 (sec) , antiderivative size = 290, normalized size of antiderivative = 1.14 \[ \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=\frac {\frac {2 \, {\left ({\left ({\left (A - C\right )} a + B b\right )} c^{2} - 2 \, {\left (B a - {\left (A - C\right )} b\right )} c d - {\left ({\left (A - C\right )} a + B b\right )} d^{2}\right )} {\left (f x + e\right )}}{a^{2} + b^{2}} + \frac {2 \, {\left ({\left (C a^{2} b^{2} - B a b^{3} + A b^{4}\right )} c^{2} - 2 \, {\left (C a^{3} b - B a^{2} b^{2} + A a b^{3}\right )} c d + {\left (C a^{4} - B a^{3} b + A a^{2} b^{2}\right )} d^{2}\right )} \log \left (b \tan \left (f x + e\right ) + a\right )}{a^{2} b^{3} + b^{5}} + \frac {{\left ({\left (B a - {\left (A - C\right )} b\right )} c^{2} + 2 \, {\left ({\left (A - C\right )} a + B b\right )} c d - {\left (B a - {\left (A - C\right )} b\right )} d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{2} + b^{2}} + \frac {C b d^{2} \tan \left (f x + e\right )^{2} + 2 \, {\left (2 \, C b c d - {\left (C a - B b\right )} d^{2}\right )} \tan \left (f x + e\right )}{b^{2}}}{2 \, f} \]

input
integrate((c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(a+b*tan(f*x+ 
e)),x, algorithm="maxima")
 
output
1/2*(2*(((A - C)*a + B*b)*c^2 - 2*(B*a - (A - C)*b)*c*d - ((A - C)*a + B*b 
)*d^2)*(f*x + e)/(a^2 + b^2) + 2*((C*a^2*b^2 - B*a*b^3 + A*b^4)*c^2 - 2*(C 
*a^3*b - B*a^2*b^2 + A*a*b^3)*c*d + (C*a^4 - B*a^3*b + A*a^2*b^2)*d^2)*log 
(b*tan(f*x + e) + a)/(a^2*b^3 + b^5) + ((B*a - (A - C)*b)*c^2 + 2*((A - C) 
*a + B*b)*c*d - (B*a - (A - C)*b)*d^2)*log(tan(f*x + e)^2 + 1)/(a^2 + b^2) 
 + (C*b*d^2*tan(f*x + e)^2 + 2*(2*C*b*c*d - (C*a - B*b)*d^2)*tan(f*x + e)) 
/b^2)/f
 
3.1.61.8 Giac [A] (verification not implemented)

Time = 0.70 (sec) , antiderivative size = 331, normalized size of antiderivative = 1.30 \[ \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=\frac {\frac {2 \, {\left (A a c^{2} - C a c^{2} + B b c^{2} - 2 \, B a c d + 2 \, A b c d - 2 \, C b c d - A a d^{2} + C a d^{2} - B b d^{2}\right )} {\left (f x + e\right )}}{a^{2} + b^{2}} + \frac {{\left (B a c^{2} - A b c^{2} + C b c^{2} + 2 \, A a c d - 2 \, C a c d + 2 \, B b c d - B a d^{2} + A b d^{2} - C b d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{2} + b^{2}} + \frac {2 \, {\left (C a^{2} b^{2} c^{2} - B a b^{3} c^{2} + A b^{4} c^{2} - 2 \, C a^{3} b c d + 2 \, B a^{2} b^{2} c d - 2 \, A a b^{3} c d + C a^{4} d^{2} - B a^{3} b d^{2} + A a^{2} b^{2} d^{2}\right )} \log \left ({\left | b \tan \left (f x + e\right ) + a \right |}\right )}{a^{2} b^{3} + b^{5}} + \frac {C b d^{2} \tan \left (f x + e\right )^{2} + 4 \, C b c d \tan \left (f x + e\right ) - 2 \, C a d^{2} \tan \left (f x + e\right ) + 2 \, B b d^{2} \tan \left (f x + e\right )}{b^{2}}}{2 \, f} \]

input
integrate((c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(a+b*tan(f*x+ 
e)),x, algorithm="giac")
 
output
1/2*(2*(A*a*c^2 - C*a*c^2 + B*b*c^2 - 2*B*a*c*d + 2*A*b*c*d - 2*C*b*c*d - 
A*a*d^2 + C*a*d^2 - B*b*d^2)*(f*x + e)/(a^2 + b^2) + (B*a*c^2 - A*b*c^2 + 
C*b*c^2 + 2*A*a*c*d - 2*C*a*c*d + 2*B*b*c*d - B*a*d^2 + A*b*d^2 - C*b*d^2) 
*log(tan(f*x + e)^2 + 1)/(a^2 + b^2) + 2*(C*a^2*b^2*c^2 - B*a*b^3*c^2 + A* 
b^4*c^2 - 2*C*a^3*b*c*d + 2*B*a^2*b^2*c*d - 2*A*a*b^3*c*d + C*a^4*d^2 - B* 
a^3*b*d^2 + A*a^2*b^2*d^2)*log(abs(b*tan(f*x + e) + a))/(a^2*b^3 + b^5) + 
(C*b*d^2*tan(f*x + e)^2 + 4*C*b*c*d*tan(f*x + e) - 2*C*a*d^2*tan(f*x + e) 
+ 2*B*b*d^2*tan(f*x + e))/b^2)/f
 
3.1.61.9 Mupad [B] (verification not implemented)

Time = 10.71 (sec) , antiderivative size = 325, normalized size of antiderivative = 1.28 \[ \int \frac {(c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (\frac {B\,d^2+2\,C\,c\,d}{b}-\frac {C\,a\,d^2}{b^2}\right )}{f}+\frac {\ln \left (a+b\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (b^2\,\left (C\,a^2\,c^2+2\,B\,a^2\,c\,d+A\,a^2\,d^2\right )-b\,\left (B\,a^3\,d^2+2\,C\,c\,a^3\,d\right )-b^3\,\left (B\,a\,c^2+2\,A\,a\,d\,c\right )+A\,b^4\,c^2+C\,a^4\,d^2\right )}{f\,\left (a^2\,b^3+b^5\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (A\,d^2-A\,c^2+B\,c^2\,1{}\mathrm {i}-B\,d^2\,1{}\mathrm {i}+C\,c^2-C\,d^2+A\,c\,d\,2{}\mathrm {i}+2\,B\,c\,d-C\,c\,d\,2{}\mathrm {i}\right )}{2\,f\,\left (b+a\,1{}\mathrm {i}\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (B\,c^2-B\,d^2+2\,A\,c\,d-2\,C\,c\,d-A\,c^2\,1{}\mathrm {i}+A\,d^2\,1{}\mathrm {i}+C\,c^2\,1{}\mathrm {i}-C\,d^2\,1{}\mathrm {i}+B\,c\,d\,2{}\mathrm {i}\right )}{2\,f\,\left (a+b\,1{}\mathrm {i}\right )}+\frac {C\,d^2\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,b\,f} \]

input
int(((c + d*tan(e + f*x))^2*(A + B*tan(e + f*x) + C*tan(e + f*x)^2))/(a + 
b*tan(e + f*x)),x)
 
output
(tan(e + f*x)*((B*d^2 + 2*C*c*d)/b - (C*a*d^2)/b^2))/f + (log(a + b*tan(e 
+ f*x))*(b^2*(A*a^2*d^2 + C*a^2*c^2 + 2*B*a^2*c*d) - b*(B*a^3*d^2 + 2*C*a^ 
3*c*d) - b^3*(B*a*c^2 + 2*A*a*c*d) + A*b^4*c^2 + C*a^4*d^2))/(f*(b^5 + a^2 
*b^3)) + (log(tan(e + f*x) + 1i)*(A*d^2 - A*c^2 + B*c^2*1i - B*d^2*1i + C* 
c^2 - C*d^2 + A*c*d*2i + 2*B*c*d - C*c*d*2i))/(2*f*(a*1i + b)) + (log(tan( 
e + f*x) - 1i)*(A*d^2*1i - A*c^2*1i + B*c^2 - B*d^2 + C*c^2*1i - C*d^2*1i 
+ 2*A*c*d + B*c*d*2i - 2*C*c*d))/(2*f*(a + b*1i)) + (C*d^2*tan(e + f*x)^2) 
/(2*b*f)